
/*

Design Pattern Automation Toolkit.
Application to create applications with emphasis on Design patterns.
And support for round trip engineering.
Copyright (C) 2004 Vineeth Neelakant. nvineeth@gmail.com

This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.

*/
using System;
using BusinessLayer;
using InfoClasses;
using dpatoolkit.UILayer;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;

namespace dpatoolkit.UILayer
{
    /// <summary>
    /// Summary description for ParameterEditForm.
    /// </summary>
    public class ParameterEditForm : System.Windows.Forms.Form
    {
        private System.Windows.Forms.Label label5;
        private System.Windows.Forms.TextBox summaryTextBox;
        private System.Windows.Forms.Button cancelButton;
        private System.Windows.Forms.Button okButton;
        private System.Windows.Forms.Label label1;
        private System.Windows.Forms.TextBox paramNameTextBox;
        private System.Windows.Forms.TextBox paramTypeTextBox;
        private System.Windows.Forms.Label label3;
        private System.Windows.Forms.Button metaInfoButton;
        /// <summary>
        /// Required designer variable.
        /// </summary>
        private System.ComponentModel.Container components = null;

        public ParameterEditForm()
        {
            //
            // Required for Windows Form Designer support
            //
            InitializeComponent();

            //
            // TODO: Add any constructor code after InitializeComponent call
            //
        }

        /// <summary>
        /// Clean up any resources being used.
        /// </summary>
        protected override void Dispose(bool disposing)
        {
            if (disposing)
            {
                if (components != null)
                {
                    components.Dispose();
                }
            }
            base.Dispose(disposing);
        }

        #region Windows Form Designer generated code
        /// <summary>
        /// Required method for Designer support - do not modify
        /// the contents of this method with the code editor.
        /// </summary>
        private void InitializeComponent()
        {
            this.label5 = new System.Windows.Forms.Label();
            this.paramNameTextBox = new System.Windows.Forms.TextBox();
            this.summaryTextBox = new System.Windows.Forms.TextBox();
            this.paramTypeTextBox = new System.Windows.Forms.TextBox();
            this.cancelButton = new System.Windows.Forms.Button();
            this.okButton = new System.Windows.Forms.Button();
            this.label1 = new System.Windows.Forms.Label();
            this.label3 = new System.Windows.Forms.Label();
            this.metaInfoButton = new System.Windows.Forms.Button();
            this.SuspendLayout();
            // 
            // label5
            // 
            this.label5.Location = new System.Drawing.Point(8, 76);
            this.label5.Name = "label5";
            this.label5.Size = new System.Drawing.Size(128, 24);
            this.label5.TabIndex = 38;
            this.label5.Text = "Parameter Name";
            this.label5.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
            // 
            // paramNameTextBox
            // 
            this.paramNameTextBox.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
                | System.Windows.Forms.AnchorStyles.Left)
                | System.Windows.Forms.AnchorStyles.Right)));
            this.paramNameTextBox.Location = new System.Drawing.Point(136, 78);
            this.paramNameTextBox.Name = "paramNameTextBox";
            this.paramNameTextBox.Size = new System.Drawing.Size(280, 20);
            this.paramNameTextBox.TabIndex = 1;
            this.paramNameTextBox.Text = "paramName";
            // 
            // summaryTextBox
            // 
            this.summaryTextBox.AcceptsReturn = true;
            this.summaryTextBox.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
                | System.Windows.Forms.AnchorStyles.Left)
                | System.Windows.Forms.AnchorStyles.Right)));
            this.summaryTextBox.Location = new System.Drawing.Point(136, 120);
            this.summaryTextBox.Multiline = true;
            this.summaryTextBox.Name = "summaryTextBox";
            this.summaryTextBox.ScrollBars = System.Windows.Forms.ScrollBars.Both;
            this.summaryTextBox.Size = new System.Drawing.Size(280, 64);
            this.summaryTextBox.TabIndex = 2;
            this.summaryTextBox.Text = "";
            // 
            // paramTypeTextBox
            // 
            this.paramTypeTextBox.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
                | System.Windows.Forms.AnchorStyles.Left)
                | System.Windows.Forms.AnchorStyles.Right)));
            this.paramTypeTextBox.Location = new System.Drawing.Point(136, 32);
            this.paramTypeTextBox.Name = "paramTypeTextBox";
            this.paramTypeTextBox.Size = new System.Drawing.Size(280, 20);
            this.paramTypeTextBox.TabIndex = 0;
            this.paramTypeTextBox.Text = "ParamType";
            // 
            // cancelButton
            // 
            this.cancelButton.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
                | System.Windows.Forms.AnchorStyles.Left)
                | System.Windows.Forms.AnchorStyles.Right)));
            this.cancelButton.DialogResult = System.Windows.Forms.DialogResult.Cancel;
            this.cancelButton.Location = new System.Drawing.Point(344, 224);
            this.cancelButton.Name = "cancelButton";
            this.cancelButton.Size = new System.Drawing.Size(80, 24);
            this.cancelButton.TabIndex = 5;
            this.cancelButton.Text = "&CANCEL";
            // 
            // okButton
            // 
            this.okButton.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
                | System.Windows.Forms.AnchorStyles.Left)
                | System.Windows.Forms.AnchorStyles.Right)));
            this.okButton.DialogResult = System.Windows.Forms.DialogResult.OK;
            this.okButton.Location = new System.Drawing.Point(240, 224);
            this.okButton.Name = "okButton";
            this.okButton.TabIndex = 4;
            this.okButton.Text = "&OK";
            this.okButton.Click += new System.EventHandler(this.okButton_Click);
            // 
            // label1
            // 
            this.label1.Location = new System.Drawing.Point(8, 32);
            this.label1.Name = "label1";
            this.label1.Size = new System.Drawing.Size(128, 24);
            this.label1.TabIndex = 33;
            this.label1.Text = "Parameter Type";
            this.label1.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
            // 
            // label3
            // 
            this.label3.Location = new System.Drawing.Point(16, 120);
            this.label3.Name = "label3";
            this.label3.TabIndex = 40;
            this.label3.Text = "Summary";
            this.label3.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
            // 
            // metaInfoButton
            // 
            this.metaInfoButton.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
                | System.Windows.Forms.AnchorStyles.Left)
                | System.Windows.Forms.AnchorStyles.Right)));
            this.metaInfoButton.FlatStyle = System.Windows.Forms.FlatStyle.System;
            this.metaInfoButton.Location = new System.Drawing.Point(32, 224);
            this.metaInfoButton.Name = "metaInfoButton";
            this.metaInfoButton.Size = new System.Drawing.Size(96, 23);
            this.metaInfoButton.TabIndex = 3;
            this.metaInfoButton.Text = "M&etaInfo >>";
            this.metaInfoButton.Click += new System.EventHandler(this.metaInfoButton_Click);
            // 
            // ParameterEditForm
            // 
            this.AcceptButton = this.okButton;
            this.AutoScaleBaseSize = new System.Drawing.Size(5, 13);
            this.CancelButton = this.cancelButton;
            this.ClientSize = new System.Drawing.Size(432, 262);
            this.Controls.Add(this.metaInfoButton);
            this.Controls.Add(this.label3);
            this.Controls.Add(this.label5);
            this.Controls.Add(this.paramNameTextBox);
            this.Controls.Add(this.summaryTextBox);
            this.Controls.Add(this.paramTypeTextBox);
            this.Controls.Add(this.cancelButton);
            this.Controls.Add(this.okButton);
            this.Controls.Add(this.label1);
            this.Name = "ParameterEditForm";
            this.Text = "ParameterEditForm";
            this.ResumeLayout(false);

        }
        #endregion

        private string paramName, paramType, summary;

        private void okButton_Click(object sender, System.EventArgs e)
        {
            //MessageBox.Show("Inseid ok handler");
            this.paramName = this.paramNameTextBox.Text;
            this.paramType = this.paramTypeTextBox.Text;
            this.summary = this.summaryTextBox.Text;
            if (this.paramName.Length == 0 || this.ParamType.Length == 0)
            {
                ErrorMessage.Show("Parameter Name or Parameter Type cannot be null,\n these modifications will not be added", "Value required");
                this.error = true;
                return;
            }




        }

        public string ParamType
        {
            get { return this.paramType; }
            set { this.paramTypeTextBox.Text = value; }
        }
        public string ParamName
        {
            get { return this.paramName; }
            set { this.paramNameTextBox.Text = value; }
        }
        public string Summary
        {
            set { this.summaryTextBox.Text = value; }
            get { return this.summary; }
        }
        private bool error = false;
        public bool HasErrors()
        {
            return error;
        }

        private string metaInfo = "";
        public string MetaInfo
        {
            get
            {
                return this.metaInfo;
            }
            set
            {
                this.metaInfo = value;
            }

        }

        private void metaInfoButton_Click(object sender, System.EventArgs e)
        {
            MetaInfoEditor mie = new MetaInfoEditor(this.metaInfo);
            if (mie.ShowDialog() == DialogResult.Cancel)
                return;
            this.metaInfo = mie.MetaInfo;

        }

    }
}